import java.util.Scanner;


/**
 * @author LXH
 * @Title:
 * @Description:
 * @date 2020/4/2223:28
 */
public class Management {
    public static void main(String[] args) {
        //用户输入课程数量，依次输入所有课程名
        System.out.print("请输入课程数量:");
        Scanner courseNum = new Scanner(System.in);
        Course[] courses = new Course[courseNum.nextInt()];
        for (int i = 0; i < courses.length; i++) {
            courses[i] = new Course();
            System.out.print("请输入课程名:");
            Scanner courseName = new Scanner(System.in);
            courses[i].setName(courseName.nextLine());
        }
        //用户输入学生数量，依次输入所有学生信息和该学生所选课
        System.out.print("\n");
        System.out.print("请输入学生数量：");
        Scanner studentNum = new Scanner(System.in);
        Student[] students = new Student[studentNum.nextInt()];
        for (int i = 0; i < students.length; i++) {
            students[i] = new Student();
            System.out.print("请输入学生名字：");
            Scanner studentName = new Scanner(System.in);
            students[i].setName(studentName.nextLine());
            System.out.print("\n");
            System.out.print("请输入学生选课数量，且数量不得大于" + courses.length);
            Scanner chooseCourse = new Scanner(System.in);
            int choose = chooseCourse.nextInt();
            if (choose <= courses.length) {
                System.out.print("\n");
                System.out.print("现在有这些课，请选择序号：");
                for (int j = 0; j < courses.length; j++) {
                    System.out.print(j + "." + courses[j].getName() + " ");
                }
                for (int ij = 1; ij < choose; ij++){
                    System.out.print("\n");
                    System.out.print("第" + ij + "次，请选择序号：");
                    Scanner studentSelect = new Scanner(System.in);
                    int select = studentSelect.nextInt();
                    students[i].getCourses().add(courses[select].getName());
                    courses[select].getStudents().add(students[i].getName());
                }
            }
        }
        System.out.print("\n");
        System.out.print("");
        //输出结果
    }
}
